package com.handinfo.android.game;

import android.graphics.Bitmap;

import com.handinfo.android.DWGameManager;
import com.handinfo.android.core.graphics.DWBitmap;
import com.handinfo.android.core.graphics.DWGraphics;

public class ActorBuffer implements IIcon
{
	public static final byte TYPE_BUF = 0;
	public static final byte TYPE_DEBUF = 1;

	public static DWBitmap s_icon;
	private Bitmap m_icon;
	public byte m_type = 0;
	// public short m_id
	public long m_guid = 0;
	public int m_duration; // 伤害持续帧数

	public void init(GameActor host, byte type, long id, short iconId,
			int duration)
	{
		m_type = type;
		m_guid = id;
		m_icon = IconManger.getInstance().getIcon(iconId);
		m_duration = duration * DWGameManager.FRAME_PER_SECOND;
	}

	public void draw(DWGraphics g, int x, int y, int w, int h, int anchor)
	{
		// 当持续时间低于3秒后开始闪烁
		if (m_duration > 30 || m_duration % 10 < 5) {
			if (m_icon != null) {
				g.drawRegion(m_icon, 0, 0, m_icon.getWidth(),
						m_icon.getHeight(), 0, x, y, w, h, anchor);
			}
		}
		m_duration--;
	}

	public void drawIcon(DWGraphics g, int x, int y, int w, int h, int anchor)
	{
		// 当持续时间低于3秒后开始闪烁
		if (m_duration > 30 || m_duration % 10 < 5) {
			if (m_icon != null) {
				g.drawBitmap(m_icon, x, y, anchor);
//				g.drawRegion(m_icon, 0, 0, m_icon.getWidth(),
//						m_icon.getHeight(), 0, x, y, w, h, anchor);
			}
		}
		m_duration--;
	}

	public void drawIcon(DWGraphics g, int x, int y, int w, int h, float scaleX, float scaleY, int anchor)
	{
		// 当持续时间低于3秒后开始闪烁
		if (m_duration > 30 || m_duration % 10 < 5) {
			if (m_icon != null) {
				g.drawBitmap(m_icon, x, y, anchor);
//				g.drawRegion(m_icon, 0, 0, m_icon.getWidth(),
//						m_icon.getHeight(), 0, x, y, w, h, anchor);
			}
		}
		m_duration--;
	}
	
	
}
